package com.moli.iov.handle.alarm.enums;

import java.util.HashSet;
import java.util.Set;

public enum  AlarmCategoryEnum {

    RISK_OFFLINE_ALARM(1,"车辆失联报警"),

    DEVICE_ALARM(2, "车载终端报警"),

    FENCE_ALARM(3, "电子围栏报警");

    private int flag;

    private String msg;

    public int getFlag(){
        return flag;
    }

    AlarmCategoryEnum(int flag, String msg){
        this.flag = flag;
        this.msg = msg;
    }

    public static Set<Integer> getAlarmCodes(int flag){
        Set<Integer> list = new HashSet<>();
        switch (flag){
            case 1 :
                list.add(AlarmCodeEnum.OFF_LINE.getFlag());
                break;
            case 2:
                list = new HashSet<>(AlarmCodeEnum.getTerminalAlarms());
                break;
            case 3:
                list.add(AlarmCodeEnum.IN_FENCE.getFlag());
                list.add(AlarmCodeEnum.OUT_FENCE.getFlag());
                break;
            default:
                break;
        }
        return list;
    }

    public static String getMsg(int flag){
        for(AlarmCategoryEnum e : AlarmCategoryEnum.values()){
            if(e.flag == flag){
                return e.msg;
            }
        }
        return "";
    }

    public static AlarmCategoryEnum getEnum(int flag){
        for(AlarmCategoryEnum e : AlarmCategoryEnum.values()){
            if(e.flag == flag){
                return e;
            }
        }
        return null;
    }
}
